package com.yml.logistical.controller;

import com.yml.logistical.api.LogisticalControllerApi;
import com.yml.logistical.domain.Logistical;
import com.yml.logistical.domain.LogisticalResult;
import com.yml.logistical.domain.Shop;
import com.yml.logistical.service.LogisticalService;
import com.yml.month.response.QueryResponseResult;
import com.yml.month.response.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/logistical")
public class LogisticalController implements LogisticalControllerApi {

    @Autowired
    private LogisticalService logisticalService;

    @GetMapping("/list/{page}/{size}")
    @Override
    public QueryResponseResult list(@PathVariable("page") Integer page, @PathVariable("size")Integer size, LogisticalResult logisticalResult) {
        return logisticalService.list(page,size,logisticalResult);
    }

    @Override
    @PostMapping("/add")
    public ResponseResult add(@RequestBody Logistical logistical) {
        return logisticalService.add(logistical);
    }

    @DeleteMapping("/del/{id}")
    @Override
    public ResponseResult del(@PathVariable("id") Integer id) {
        return logisticalService.del(id);
    }

    @GetMapping("getById/{id}")
    @Override
    public Logistical getById(@PathVariable("id") Integer id) {
        return logisticalService.getById(id);
    }

    @GetMapping("/list")
    public QueryResponseResult listShop() {
        return logisticalService.listShop();
    }

    @Override
    @PostMapping("/addShop")
    public ResponseResult addShop(@RequestBody  Shop shop) {
        return logisticalService.addShop(shop);
    }

    @DeleteMapping("/delShop/{sid}")
    @Override
    public ResponseResult delShop(@PathVariable("sid") Integer sid) {
        return logisticalService.delShop(sid);
    }

    @GetMapping("/ShopById/{sid}")
    @Override
    public Shop ShopById(@PathVariable("sid") Integer sid) {
        return logisticalService.GetShopById(sid);
    }

    @PutMapping("/updateShop/{sid}")
    @Override
    public ResponseResult updateShop(@RequestBody Shop shop, @PathVariable("sid") Integer sid) {
        return logisticalService.updateShop(shop,sid);
    }


}
